﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nature.Toolkit.GMix;

namespace Nature.Data.GMixMarkup
{
    public partial class GMixParameter : IRhsEnumerable
    {
        IEnumerable<double> CreateEnumerable()
        {
            Func<double, double> increment = (cur) => this.Increment;
            if (this.IsIncrementRelative)
            {
                increment = (cur) => cur * 0.01d * this.Increment;
            }
            double value = this.LowerLimit;
            for (value = this.LowerLimit; value <= this.UpperLimit; value += increment(value))
            {
                yield return value;
            }
            if (value < this.UpperLimit) { yield return this.UpperLimit; }
        }

        #region IRhsEnumerable Members

        string IRhsEnumerable.ParameterName
        {
            get { return this.ParameterID; }
        }

        #endregion

        #region IEnumerable<double> Members

        IEnumerator<double> IEnumerable<double>.GetEnumerator()
        {
            return CreateEnumerable().GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return CreateEnumerable().GetEnumerator();
        }

        #endregion
    }
}
